﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ThanhCongJSC.Code
{
    public class MVCHelper
    {
        #region Get/Set Session
        public static string GetSession(string sessionName)
        {
            if (HttpContext.Current.Session[sessionName] != null)
                return HttpContext.Current.Session[sessionName].ToString();
            else
                return string.Empty;
        }

        public static void SetSession(string sessionName, string sessionValue)
        {
            if (string.IsNullOrEmpty(sessionValue))
            {
                HttpContext.Current.Session[sessionName] = null;
                return;
            }

            HttpContext.Current.Session[sessionName] = sessionValue;
            HttpContext.Current.Session.Timeout = 10;
        }
        #endregion

        public static bool CheckAccessRight()
        {
            if (string.IsNullOrEmpty(GetSession("UserName")))
                return false;
            else
                return true;
        }
    }
}